<?php

use App\Http\Controllers\Admin\AdminController;
use App\Http\Controllers\Admin\AuthController;
use App\Http\Controllers\Admin\CommonController;
use App\Http\Controllers\Admin\ConfigController;
use App\Http\Controllers\Admin\CouponController;
use App\Http\Controllers\Admin\CourseColumnController;
use App\Http\Controllers\Admin\CourseController;
use App\Http\Controllers\Admin\DocumentCategoryController;
use App\Http\Controllers\Admin\DocumentController;
use App\Http\Controllers\Admin\DocumentOrderController;
use App\Http\Controllers\Admin\FeedbackController;
use App\Http\Controllers\Admin\GroupBuyController;
use App\Http\Controllers\Admin\KnowledgePostController;
use App\Http\Controllers\Admin\LearnVideoChapterController;
use App\Http\Controllers\Admin\LearnVideoController;
use App\Http\Controllers\Admin\LearnVideoSectionController;
use App\Http\Controllers\Admin\NetCourseController;
use App\Http\Controllers\Admin\PaperController;
use App\Http\Controllers\Admin\Qh_ArticleController;
use App\Http\Controllers\Admin\Qh_BannerController;
use App\Http\Controllers\Admin\Qh_CdkeyController;
use App\Http\Controllers\Admin\Qh_CdkeyGroupController;
use App\Http\Controllers\Admin\Qh_CourseController;
use App\Http\Controllers\Admin\Qh_KnowledgeController;
use App\Http\Controllers\Admin\Qh_LitQuestionController;
use App\Http\Controllers\Admin\Qh_MiniProgramComponentController;
use App\Http\Controllers\Admin\Qh_NetCourseCdkeyController;
use App\Http\Controllers\Admin\Qh_NetCourseCdkeyGroupController;
use App\Http\Controllers\Admin\Qh_NoticeController;
use App\Http\Controllers\Admin\Qh_OrderController;
use App\Http\Controllers\Admin\Qh_QuestionController;
use App\Http\Controllers\Admin\Qh_QuestionLibraryController;
use App\Http\Controllers\Admin\QuestionController;
use App\Http\Controllers\Admin\QuestionReportController;
use App\Http\Controllers\Admin\SchoolArticleController;
use App\Http\Controllers\Admin\SchoolController;
use App\Http\Controllers\Admin\SchoolPlanController;
use App\Http\Controllers\Admin\SchoolSpecController;
use App\Http\Controllers\Admin\UserController;
use App\Http\Controllers\Admin\VideoLibraryController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| ADMIN Routes
|--------------------------------------------------------------------------
|
| Here is where you can register ADMIN routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "admin" middleware group. Enjoy building your API!
|
*/

Route::prefix('auth')->group(function () {
    Route::post('login', [AuthController::class, 'login']);
    Route::post('refreshToken', [AuthController::class, 'refreshToken']);
});

Route::prefix('common')->group(function () {
    Route::get('initData', [CommonController::class, 'getInitData']);
    Route::post('upload', [CommonController::class, 'getOssUploadToken']);
    Route::post('uploadByImport', [CommonController::class, 'uploadByImport']);
    Route::post('uploadFile', [CommonController::class, 'uploadFile']);
    Route::get('getProvinceLibrary', [CommonController::class, 'getProvinceLibrary']);
});

Route::middleware('auth:admin')->group(function () {
    Route::resource('admin', AdminController::class)->only('index', 'store', 'update', 'destroy');
    Route::resource('user', UserController::class)->only('index', 'update', 'destroy');
    Route::post('userStatus', [UserController::class, 'changeStatus']);
    Route::post('userExport', [UserController::class, 'userExport']);
    Route::resource('knowledgePost', KnowledgePostController::class);
    Route::get('knowledgeOptions', [KnowledgePostController::class, 'getKnowledgeOptions']);
    Route::get('userInfo/{id}', [UserController::class, 'getUserInfo']);

    Route::resource('feedback', FeedbackController::class)->only(['index', 'destroy']);
    Route::resource('questionReport', QuestionReportController::class)->only(['index', 'destroy', 'show']);
    Route::post('questionReportHide/{id}', [QuestionReportController::class, 'hide']);
    Route::delete('questionReportBatchDelete', [QuestionReportController::class, 'batchDelete']);

    Route::resource('paper', PaperController::class);
    Route::get('courseOptions', [CourseController::class, 'getOptions']);

    // 试卷导入
    Route::post('paperImport', [PaperController::class, 'import']);
    Route::post('paperPass', [PaperController::class, 'pass']);

    Route::prefix('tk')->group(function () {
        Route::resource('question', QuestionController::class)->only('index', 'destroy');
        Route::post('questionImport', [QuestionController::class, 'import']);
        Route::get('getQuestionCascadeOptions', [QuestionController::class, 'getQuestionCascadeOptions']);
    });

    // 启航专属
    Route::prefix('qh')->group(function () {
        Route::resource('notice', Qh_NoticeController::class);
        Route::resource('article', Qh_ArticleController::class);
        Route::resource('banner', Qh_BannerController::class);
        Route::resource('cdkeyGroup', Qh_CdkeyGroupController::class)->only('index', 'store', 'update', 'destroy');
        Route::resource('cdkey', Qh_CdkeyController::class)->only('index', 'destroy');
        // 激活码 冻结/解冻
        Route::post('cdkeyFreeze/{id}', [Qh_CdkeyController::class, 'freeze']);
        Route::post('cdkeyExtend', [Qh_CdkeyController::class, 'extend']);
        //导出
        Route::post('cdkeyExport', [Qh_CdkeyController::class, 'export']);
        Route::post('cdkeyGroupExport/{id}', [Qh_CdkeyGroupController::class, 'export']);
        Route::delete('cdkeyBatchDelete', [Qh_CdkeyController::class, 'cdkeyBatchDelete']);
        // Route::post('cdkeyBatch', [Qh_CdkeyController::class, 'cdkeyBatchCreate']);
        Route::resource('course', Qh_CourseController::class);
        Route::get('courseOptions', [Qh_CourseController::class, 'getOptions']);
        Route::resource('knowledge', Qh_KnowledgeController::class);
        Route::get('knowledgeOptions', [Qh_KnowledgeController::class, 'getOptions']);
        Route::resource('order', Qh_OrderController::class);
        Route::post('orderRefund/{id}', [Qh_OrderController::class, 'refund']); // 退款
        Route::resource('question', Qh_QuestionController::class);
        Route::resource('litQuestion', Qh_LitQuestionController::class);
        Route::delete('questionDeleteByIds', [Qh_QuestionController::class, 'questionDeleteByIds']);    // 批量删除
        Route::delete('litQuestionDeleteByIds', [Qh_LitQuestionController::class, 'questionDeleteByIds']);    // 小题批量删除
        Route::post('questionImport', [Qh_QuestionController::class, 'import']);
        Route::post('questionImportByExcel', [Qh_QuestionController::class, 'importByExcel']);
        Route::post('questionOutputByExcel', [Qh_QuestionController::class, 'outputByExcel']);
        Route::post('questionAllOutputByExcel', [Qh_QuestionController::class, 'outputAllByExcel']);
        Route::get('getQuestionCascadeOptions', [Qh_QuestionController::class, 'getCascadeOptions']);
        Route::get('getKnowledgeOptionsByLevel2', [Qh_QuestionController::class, 'getKnowledgeOptionsByLevel2']);
        Route::resource('questionLibrary', Qh_QuestionLibraryController::class);
        Route::get('questionLibraryOptions', [Qh_QuestionLibraryController::class, 'getOptions']);
        Route::get('getQuestionOptions', [Qh_QuestionController::class, 'getQuestionOptions']);
        Route::get('getSchoolSpecOptions', [SchoolSpecController::class, 'getSpecOptions']);
        Route::get('getSchoolSpecOptions2', [SchoolSpecController::class, 'getSpecOptions2']);

        // 组件管理
        Route::resource('miniProgramComponent', Qh_MiniProgramComponentController::class);

        // 页面配置
        Route::get('getHomeConfig', [ConfigController::class, 'getHomeConfig']);
        Route::post('saveHomeConfig', [ConfigController::class, 'saveHomeConfig']);
        Route::get('getWangkeConfig', [ConfigController::class, 'getWangkeConfig']);
        Route::post('saveWangkeConfig', [ConfigController::class, 'saveWangkeConfig']);
        Route::get('getKaoshiConfig', [ConfigController::class, 'getKaoshiConfig']);
        Route::post('saveKaoshiConfig', [ConfigController::class, 'saveKaoshiConfig']);
        Route::get('getSchoolConfig', [ConfigController::class, 'getSchoolConfig']);
        Route::post('saveSchoolConfig', [ConfigController::class, 'saveSchoolConfig']);
        Route::get('getGlobalConfig', [ConfigController::class, 'getGlobalConfig']);
        Route::post('saveGlobalConfig', [ConfigController::class, 'saveGlobalConfig']);
        Route::get('getDocumentConfig', [ConfigController::class, 'getDocumentConfig']);
        Route::post('saveDocumentConfig', [ConfigController::class, 'saveDocumentConfig']);

        // 学校
        Route::resource('school', SchoolController::class);
        Route::resource('schoolArticle', SchoolArticleController::class);
        Route::resource('schoolSpec', SchoolSpecController::class);
        Route::resource('schoolPlan', SchoolPlanController::class);
        // 导入学校
        Route::post('schoolImport', [SchoolController::class, 'import']);

        // 文档
        Route::resource('document', DocumentController::class);
        Route::resource('documentCategory', DocumentCategoryController::class);
        Route::resource('documentOrder', DocumentOrderController::class)->only('index', 'destroy');
        Route::get('documentOptions', [DocumentController::class, 'getOptions']);
        Route::get('documentCategoryOptions', [DocumentCategoryController::class, 'getOptions']);
        Route::get('documentTagOptions', [DocumentController::class, 'getTagOptions']);
        Route::post('documentOrderRefund/{id}', [DocumentOrderController::class, 'refund']);
        Route::post('documentOrderExpress', [DocumentOrderController::class, 'express']);

        // 视频课程
        Route::resource('learnVideo', LearnVideoController::class);
        Route::get('learnVideoOptions', [LearnVideoController::class, 'getOptions']);
        Route::resource('learnVideoChapter', LearnVideoChapterController::class);
        Route::get('learnVideoChapterOptions', [LearnVideoChapterController::class, 'getOptions']);
        Route::resource('learnVideoSection', LearnVideoSectionController::class);
        Route::get('learnVideoSectionOptions', [LearnVideoSectionController::class, 'getOptions']);
        Route::post('learnVideoSectionStoreByVideoId', [LearnVideoSectionController::class, 'storeByVideoId']);
        Route::post('learnVideoSectionStoreByExcel', [LearnVideoSectionController::class, 'storeByExcel']);
        Route::resource('videoLibrary', VideoLibraryController::class);
        Route::get('findVideoLibrary', [VideoLibraryController::class, 'find']);
        Route::get('videoLibraryOptions', [VideoLibraryController::class, 'getOptions']);

        // 专栏
        Route::resource('courseColumn', CourseColumnController::class);
        Route::get('courseColumnOptions', [CourseColumnController::class, 'getOptions']);

        // 优惠券
        Route::resource('coupon', CouponController::class);
        Route::get('couponOptions', [CouponController::class, 'getOptions']);

        // 拼团
        Route::resource('groupBuy', GroupBuyController::class);

        // 网课
        Route::resource('netCourse', NetCourseController::class);

        // 视频库
        Route::resource('videoLibrary', VideoLibraryController::class);
        Route::get('getVideoLibraryCategory', [VideoLibraryController::class, 'getCategory']);
        Route::post('storeVideoLibraryCategory', [VideoLibraryController::class, 'storeCategory']);
        Route::post('updateVideoLibraryCategory', [VideoLibraryController::class, 'updateCategory']);
        Route::delete('deleteVideoLibraryCategory', [VideoLibraryController::class, 'deleteCategory']);
        Route::post('storeVideos', [VideoLibraryController::class, 'storeVideos']);
        Route::post('importVideoByExcel', [VideoLibraryController::class, 'importVideoByExcel']);

        // 网课激活码
        Route::prefix('netCourses')->group(function () {
            Route::resource('cdkeyGroup', Qh_NetCourseCdkeyGroupController::class)->only('index', 'store', 'update', 'destroy');
            Route::resource('cdkey', Qh_NetCourseCdkeyController::class)->only('index', 'destroy');
            // 激活码 冻结/解冻
            Route::post('cdkeyFreeze/{id}', [Qh_NetCourseCdkeyController::class, 'freeze']);
            Route::post('cdkeyExtend', [Qh_NetCourseCdkeyController::class, 'extend']);
            // 导出
            Route::post('cdkeyExport', [Qh_NetCourseCdkeyController::class, 'export']);
            Route::post('cdkeyGroupExport/{id}', [Qh_NetCourseCdkeyGroupController::class, 'export']);
            Route::delete('cdkeyBatchDelete', [Qh_NetCourseCdkeyController::class, 'cdkeyBatchDelete']);
            // Route::post('cdkeyBatch', [Qh_NetCourseCdkeyController::class, 'cdkeyBatchCreate']);
            Route::resource('course', Qh_CourseController::class);
            Route::get('courseOptions', [Qh_CourseController::class, 'getOptions']);
        });

    });
});

// 模板下载
Route::get('downloadTemplate', [CommonController::class, 'downloadTemplate']);
